package org.apache.ocean.main.database;

import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;

import org.apache.ocean.ClusterRegistry;

public class DatabaseRegistry {
	Map<String, JDBCDatabase> map = new ConcurrentHashMap<String, JDBCDatabase>();

	public static DatabaseRegistry getDatabaseRegistry() {
		DatabaseRegistry databaseRegistry = (DatabaseRegistry) ClusterRegistry.get("databaseRegistry");
		if (databaseRegistry == null) {
			databaseRegistry = new DatabaseRegistry();
			ClusterRegistry.put("databaseRegistry", databaseRegistry);
		}
		return databaseRegistry;
	}

	public Set<String> getNames() {
    return map.keySet();
	}

	public JDBCDatabase get(String name) {
		return map.get(name);
	}

	public void add(JDBCDatabase database) {
		map.put(database.getName(), database);
	}
}
